#!/bin/sh

# To install:
# ln -sv $GOPATH/src/github.com/lmorg/murex/test/pre-push .git/hooks/

cd $GOPATH/src/github.com/lmorg/murex

trap ctrl_c INT

ctrl_c() {
    printf "\n\033[0;31m[PUSH CANCELLED]\033[0m\n"
    exit 1
}

set -e

echo "Running golang unit tests...."
mkdir -p ./test/tmp
go test ./... -race 

echo "Running murex behavioural tests...."
go build github.com/lmorg/murex
./murex -c 'g behavioural/*.mx -> foreach f { source $f }; test run *'

echo "Allowing git push to proceed...."
